home *** CD-ROM | disk | FTP | other *** search
- package com.sun.java.swing.plaf.metal;
-
- import com.sun.java.swing.JComponent;
- import com.sun.java.swing.JInternalFrame;
- import com.sun.java.swing.LookAndFeel;
- import com.sun.java.swing.border.Border;
- import com.sun.java.swing.border.EmptyBorder;
- import com.sun.java.swing.plaf.ComponentUI;
- import com.sun.java.swing.plaf.UIResource;
- import com.sun.java.swing.plaf.basic.BasicInternalFrameUI;
- import java.awt.Container;
- import java.beans.PropertyChangeListener;
-
- public class MetalInternalFrameUI extends BasicInternalFrameUI {
- private MetalInternalFrameTitlePane titlePane;
- private PropertyChangeListener paletteListener;
- private PropertyChangeListener contentPaneListener;
- private static final Border handyEmptyBorder = new EmptyBorder(0, 0, 0, 0);
- protected static String IS_PALETTE = "JInternalFrame.isPalette";
-
- public MetalInternalFrameUI(JInternalFrame b) {
- super(b);
- }
-
- protected JComponent createNorthPane(JInternalFrame w) {
- this.titlePane = new MetalInternalFrameTitlePane(w);
- return this.titlePane;
- }
-
- public static ComponentUI createUI(JComponent c) {
- return new MetalInternalFrameUI((JInternalFrame)c);
- }
-
- public void installUI(JComponent c) {
- super.frame = (JInternalFrame)c;
- this.paletteListener = new PaletteListener(this);
- this.contentPaneListener = new ContentPaneListener(this);
- c.addPropertyChangeListener(this.paletteListener);
- c.addPropertyChangeListener(this.contentPaneListener);
- super.installUI(c);
- Object paletteProp = c.getClientProperty(IS_PALETTE);
- if (paletteProp != null) {
- this.setPalette((Boolean)paletteProp);
- }
-
- Container content = super.frame.getContentPane();
- this.stripContentBorder(content);
- c.setOpaque(false);
- }
-
- public void setPalette(boolean isPalette) {
- if (isPalette) {
- LookAndFeel.installBorder(super.frame, "InternalFrame.paletteBorder");
- } else {
- LookAndFeel.installBorder(super.frame, "InternalFrame.border");
- }
-
- this.titlePane.setPalette(isPalette);
- }
-
- private void stripContentBorder(Object c) {
- if (c instanceof JComponent) {
- JComponent contentComp = (JComponent)c;
- Border contentBorder = contentComp.getBorder();
- if (contentBorder == null || contentBorder instanceof UIResource) {
- contentComp.setBorder(handyEmptyBorder);
- }
- }
-
- }
-
- public void uninstallUI(JComponent c) {
- c.removePropertyChangeListener(this.paletteListener);
- c.removePropertyChangeListener(this.contentPaneListener);
- Container cont = ((JInternalFrame)c).getContentPane();
- if (cont instanceof JComponent) {
- JComponent content = (JComponent)cont;
- if (content.getBorder() == handyEmptyBorder) {
- content.setBorder((Border)null);
- }
- }
-
- super.uninstallUI(c);
- }
-
- static void access$stripContentBorder(MetalInternalFrameUI var0, Object var1) {
- var0.stripContentBorder(var1);
- }
- }
-